﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

using BLL;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace DBLWebService
{
    /// <summary>
    /// Service1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
     [System.Web.Script.Services.ScriptService]
    public class SearchService : System.Web.Services.WebService
    {
        [WebMethod (Description = "在搜索框中输入搜索词时调用这个方法可以得到猜想的搜索词")]
        public DataSet GetGuessWordFromCache(string s)
        {
            return SearchBLL.GetGuessWordFromCache(s);
        }

        [WebMethod(Description = "在DB中的search_guessword表中搜索")]
        public DataSet GetGuessWordFromDB(string s)
        {
            return SearchBLL.GetGuessWordFromDB(s);
        }

        [WebMethod(Description = "删除猜测词")]
        public int DeleteGuessWordByWord(string word)
        {
            return SearchBLL.DeleteGuessWordByWord(word);
        }
        [WebMethod(Description = "新增猜测词")]
        public int AddGuessWord(string guessWord)
        {
            return SearchBLL.AddGuessWord(guessWord);
        }
        [WebMethod]
        public List<String> SplitWord(string s)
        {
           return SearchBLL.SplitWord(s);
        }

        [WebMethod(Description = "搜索已经审核的用户（供普通用户使用）searchWord搜索词，searchType搜索类型，C企业P个人S商铺O组织")]
        [XmlInclude(typeof(BLL.IntelligenceSearch.BriefInfoComparable))]
        public ArrayList SearchCompanyPersonShop(string searchWord,string searchType,int maxReturnCount)
        {
            return SearchBLL.DoSearch(searchWord, searchType.ToUpper(), maxReturnCount);
        }

        [WebMethod(Description = "搜索所有的用户（供管理员使用）searchWord搜索词，searchType搜索类型，C企业P个人S商铺O组织")]
        [XmlInclude(typeof(BLL.IntelligenceSearch.BriefInfoComparable))]
        public ArrayList SearchCompanyPersonShopOrganzationAll(string searchWord,string searchType,int maxReturnCount)
        {
            return SearchBLL.DoSearchAll(searchWord, searchType, maxReturnCount);
        }

        [WebMethod(Description = "搜索联系信息，searchWord=搜索词，searchtype=搜索类型，searchtype的取值为qq，email，weibo，website，忽略大小写")]
        public DataSet SearchContact(string searchWord, string searchtype)
        {
            if (searchtype.ToLower().Equals("email"))
            {
                //搜索email
                return SearchBLL.SearchEmail(searchWord);
            }
            else if (searchtype.ToLower().Equals("qq"))
            {
                //搜索qq
                return SearchBLL.SearchQQ(searchWord);
            }
            else if (searchtype.ToLower().Equals("weibo"))
            {
                //搜索微博
                return SearchBLL.SearchWeibo(searchWord);
            }
            else if (searchtype.ToLower().Equals("website"))
            {
                //搜索网店
                return SearchBLL.SearchWebSite(searchWord);
            }
            else
            {
                return null;
            }
        }


        [WebMethod(Description = "搜索hotword")]
        public DataSet GetHotWord(string searchWord)
        {
            return SearchBLL.GetHotWord(searchWord);
        }
        
    }
}
